/*
 * Asset.cpp
 *
 *  Created on: 09/11/2011
 *      Author: Arleudo
 */

#include "lang/Asset.h"
#include "objetos/Hero.h"
#include "objetos/Minion.h"
#include "objetos/Boss.h"

using namespace objetos;


namespace lang
{
	Asset* Asset::instance = NULL;
	//--------------------------------------------------------------------------------
	Asset::Asset( void )
	{
	}
	//--------------------------------------------------------------------------------
	Asset::~Asset( void )
	{
	}
	//--------------------------------------------------------------------------------
	sf::Image Asset::loadImage( const std::string& filename )
	{
		sf::Image img;
		img.LoadFromFile( filename );
		return img;
	}
	//--------------------------------------------------------------------------------
	void Asset::loadImages(
							const std::string& path,
							const std::string& filename,
							const std::string& extension,
							int numImages,
							std::vector<sf::Image>& target )
	{
		for ( int i = 0; i < numImages; i++ )
		{
			std::stringstream ss;
			ss << i;
			sf::Image img = loadImage( path + filename + ss.str() + extension );

			target.push_back( img );
		}
	}
	//--------------------------------------------------------------------------------
	void Asset::load( void )
	{
		//carregando o heroi do jogo
		sf::Sprite* sprite1 = new sf::Sprite();
		Hero* hero = new Hero( sprite1 );
		hero->load();

		sf::Sprite* sprite2 = new sf::Sprite();
		Minion* minion = new Minion( sprite2 );
		minion->load();

		sf::Sprite* sprite3 = new sf::Sprite();
		Boss* boss = new Boss( sprite3 );
		boss->load();

		World::getInstance()->addObject( hero );
		World::getInstance()->addObject( minion );
		World::getInstance()->addObject( boss );
	}
	//--------------------------------------------------------------------------------
	Asset* Asset::getInstance( void )
	{
		if ( !instance ) instance = new Asset();
		return instance;
	}

} // namespace name

